Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
prompt-for
Advanced tools
Prompt the user for a series of answers.
$ npm install prompt-for
var prompt = require('prompt-for');
var schema = {
name: 'string',
siblings: 'number',
birthday: 'date',
deceased: 'boolean',
secret: 'password'
};
prompt(schema, function(err, answers){
assert(answers.name == 'Ian');
assert(answers.siblings == 2);
assert(answers.birthday.getTime() == 1343260800000);
assert(answers.deceased == false);
assert(answers.secret == '1234');
});
And if you're being lazy...
prompt(['name', 'website'], function(err, answers){
assert(answers.name == 'Ian');
assert(answers.website == 'ianstormtaylor.com');
});
Or even...
prompt('name', function(err, answers){
assert(answers.name == 'Ian');
});
Define or overwrite default values...
boolean
value is falsedate
value is nowvar prompt = require('prompt-for');
var schema = {
name: {type:'string', default:'Ian'},
siblings: {type:'number', default:42},
birthday: {type:'date', default:'yesterday'},
deceased: {type:'boolean', default:true},
secret: {type:'password', default:'1234'}
};
prompt(schema, function(err, answers){
assert(answers.name == 'Ian');
// ...
});
Disable required for string
and number
...
By default, empty or incorrect answers when asked a string or a number, will be asked again. Set required
to false allows you to skip the question.
var prompt = require('prompt-for');
var schema = {
name: {type:'string', required:false},
siblings: {type:'number', required:false}
};
prompt(schema, function(err, answers){
assert(answers.name == null);
assert(answers.number == null);
});
Prompt the user with the given schema
and optional options
, then callback with fn(err, answers)
. Options default to:
{
color: null,
pad: true
}
MIT
FAQs
Prompt the user for a series of answers.
The npm package prompt-for receives a total of 613 weekly downloads. As such, prompt-for popularity was classified as not popular.
We found that prompt-for demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.